﻿using System;
using EPiServer.Core;
using EPiServer.Filters;

namespace EPiBoost.Core.Filters.PageFilters
{
    public class FilterRandom : IPageFilter
    {
        public void Filter(PageDataCollection pages)
        {
            var random = new Random();
            int total = pages.Count -1;
			for (int i = 0; i <= total; i++)
            {
				int rnd = random.Next(total);
                PageData tmp = pages[rnd];
                pages.RemoveAt(rnd); 
                pages.Insert(i, tmp); 
            }            
        }

        public void Filter(object sender, FilterEventArgs e)
        {
            Filter(e.Pages);
        }

        public bool ShouldFilter(PageData page)
        {
            throw new NotImplementedException();
        }
    }
}